package com.atguigu.oss.utils;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

//当项目一启动，spring有一个接口，spring加载之后就会执行接口的方法
@Data
@NoArgsConstructor
@Component
@ConfigurationProperties("aliyun.oss.file")
public class ContandPropertiesUtils implements InitializingBean {
    /*
aliyun.oss.file.endpoint=oss-cn-guangzhou.aliyuncs.com
aliyun.oss.file.keyid=LTAI5tB92pUa1nAAkca7eG1w
aliyun.oss.file.keysecret=6aUkZQmrpDdDA3ztXcZsPOtwBrlqgQ
aliyun.oss.file.bucketname=edu--1530242
 */
    private String endpoint;
    private String keyid;
    private String keysecret;
    private String bucketname;

    //接口表示管理过程中的时候会读取值
    //定义一些公开的静态的常量
    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyid;
        ACCESS_KEY_SECRET = keysecret;
        BUCKET_NAME = bucketname;
    }

}
